//this is a clock run in applet
//port java.io.*;
import java.applet.Applet;
import java.awt.Graphics;
import java.util.Calendar;
import java.awt.Color;
import java.awt.Font;
public class ElecClock extends Applet
{
	public void init()
		{
			
		}
	public void start()
		{
			
		}
	public void paint(Graphics g)
		{
			g.setColor(Color.RED);
			//g.setXORMode(Color.BLACK);
			g.setFont(new Font("hi",Font.BOLD,40));
			g.drawString(getCurrentTime(),100,100);
			try
				{
					Thread.sleep(20);
				}catch(Exception e)
					{
						e.printStackTrace();
					}
			repaint();
		}
	public String getCurrentTime()
		{
			Calendar cal=Calendar.getInstance();
			int hour=cal.get(Calendar.HOUR);
			int minute=cal.get(Calendar.MINUTE);
			int second=cal.get(Calendar.SECOND);
			String AM_PM;
			if(cal.get(Calendar.AM_PM)==Calendar.AM)
				AM_PM="AM";
				else
					AM_PM="PM";
			//int hour=cal.get(Calendar.HOUR);
			return String.format("%02d",hour)+":"+String.format("%02d",minute)+":"+String.format("%02d",second)+"  "+AM_PM;
		}
}
/*
<applet code="ElecClock.class" height =500 width =400>
</applet>*/
